<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			window.onload=function()
			{
				var num=0;
				var timer;
				var btn02=document.getElementById("btn02");
				document.onkeydown=function(event)
				{
					event=event||window.event;
					if(event.ctrlKey)
					{
						console.log("滚动了");
						clearInterval(timer);  //这个函数可以传undefined
						var imgArr=["../img/富尔恣.png","../img/穆雷.png","../img/沃克.png","../img/小波特.png"];
						var hArr=["富尔恣","穆雷","沃克","小波特"];
						 timer=setInterval(function()   //如果这里的timer加var 那么点按钮就会创建很多个计时器
						{
							
							var img1=document.getElementById("img1");
							var h1=document.getElementById("kk");
							 img1.src=imgArr[num];
							 h1.innerHTML=hArr[num];
							 num++;
							 /* if(num==4)
							 {
								 num=0;
							 } */
							 num%=imgArr.length;  /* 跟if是等价的*/
							 btn02.onclick=function()//event为什么在这里不管用
							 {
								 console.log("aa");
								 clearInterval(timer); 
							 }
					},100) 
				   }
				}
				}
		</script>
	</head>
	<body>
		<img id="img1" src="" alt="">
		<h1 id="kk"></h1>
		<button id="btn01">开始</button>
		<button id="btn02">停止</button>
	</body>
</html>